package com.zhuhai.controller;


import com.zhuhai.service.TicketInfoService;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
/**
 *  Ticket
 *  @author zhuhai
 *  @version 1.0.0.0
 */
@Controller
@RequestMapping(value = "ticketInfo")
public class TicketInfoController {
    @Resource
    private TicketInfoService ticketInfoService;

    /**
     * 获取票据列表
     * @param page
     * @param pageSize
     * @return
     */
    @GetMapping(path = "/list")
    @ResponseBody
    public Object getTicketList(@RequestParam(defaultValue = "0") final int page, @RequestParam(defaultValue = "10") final int pageSize) {
        final Pageable pageable = PageRequest.of(page, pageSize);
        return ticketInfoService.getTicketList(null, pageable).getContent();
    }

    /**
     * 使用Criteria 方式统计出每天的出票数
     * @return
     */
    @GetMapping(path = "/ticketgroup")
    @ResponseBody
    public Object getTicketgroup() {
        return ticketInfoService.getTicketgroup();
    }
}
